<template>
	<div class="myAchievements">
		<div class="classIndex_h">
			<span>我的成绩</span>
		</div>
		<!--  -->
		<div class="classNotice_search myAchievements-h  clear">
			<div class="achievement_type fl">
				<router-link to="/learn/grade/index">我的成绩</router-link>
				<router-link to="/learn/grade/growth">我的成长</router-link>
			</div>
		</div>
		<!--  -->
		<div class="myAchievements-batle" v-for="(item, index) in examResults" :key="item.id">
			<h3>{{item.catename}}</h3>
			<table>
				<thead>
					<tr>
						<th>试卷名</th>
						<th>占比</th>
						<th>得分</th>
						<th>总分</th>
						<th>班级平均分</th>
						<th>排名</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td>{{item.testname}}</td>
						<td>{{item.percent}}</td>
						<td>{{item.score}}</td>
						<td>{{item.sum_score}}</td>
						<td>{{item.ping_score}}</td>
						<td>{{item.rank}}</td>
					</tr>
				</tbody>
			</table>
			<div class="myAchievements-ej">
				<div>
					<img v-if="item._pingscore > 0" src="../../../public/images/Group7.png">
					<img v-else src="../../../public/images/Group8.png">
					<template>
						<span v-if="item._pingscore > 0">总分高出平均分
							{{Math.abs(parseInt(item._pingscore))}}分，
							比上次进步{{Math.abs(parseInt(item._score))}}分，排名上升位</span>
						<span v-else>总分低于平均分{{Math.abs(parseInt(item._pingscore))}}分，
							比上次退步{{Math.abs(parseInt(item._score))}}分，排名下降{{Math.abs(parseInt(item._rank))}}位</span>
					</template>
				</div>
				<div>
					{{item.create_name}}老师于{{item.create_time.substring(0,4)}}年{{item.create_time.substring(5,7)}}月{{item.create_time.substring(8,10)}}日发布
				</div>
			</div>
		</div>
		<div class="dependent" v-if="placeholder">
			<i class="ipm image_nofound"></i>
			<p>
				还没发现任何相关的内容哦~
			</p>
		</div>
	</div>
</template>
<script>


let tableData = [{
	id: 0,
	name: '123'
}]

export default {
	data() {
		return {
			path: this.$route.query.id,
			tableData: tableData,
			examResults: [],
			placeholder: false,
		}
	},
	watch: {

	},
	created() {
		this.getExamResults()
	},
	methods: {
		//获取科目
		getExamResults() {
			let success = res => {
				let data = res.data;
				this.examResults = data.data;
				this.placeholder = this.examResults.length === 0 ? true : false
			};
			this.$ajax({
				url: "api/statistics/student_grade_static_list",
				method: "get",
				params: {
					studentid: this.$g.user_id,
					classid: this.path,
					order: 'time'
				},
				func: {
					success: success
				}
			});
		},
	}
}
</script>